﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.XLANGs.BaseTypes;
using System.Xml;
using System.Xml.Linq;
using Acme.BizTalk.Schemas.MessageTypes.Claims;

namespace Acme.BizTalk.Orchestrations.Utilities.Tests
{
    /// <summary>
    /// Tests for the claim loading process
    /// </summary>
    [TestClass]
    public class ClaimLoadingProcessHelperTests
    {
        /// <summary>
        /// Tests the count claims method
        /// </summary>
        [TestMethod]
        public void CountClaimsTest()
        {
            const string InputFilePath = @"..\..\..\Acme.BizTalk.Orchestrations.Utilities.Tests\ClaimLoadingProcessHelperTests.xml";
            XElement element = XElement.Load(InputFilePath);
            int count = ClaimLoadingProcessHelper.CountClaims(element);
            Assert.IsTrue(count == 3, "The count of claims is not as expected");
        }
        /// <summary>
        /// Tests the count claims method
        /// </summary>
        [TestMethod]
        public void CountClaimsWhenNoneTest()
        {
            const string InputFilePath = @"..\..\..\Acme.BizTalk.Orchestrations.Utilities.Tests\ClaimLoadingProcessHelperTests_CountClaimsWhenNoneTest.xml";
            XElement element = XElement.Load(InputFilePath);
            int count = ClaimLoadingProcessHelper.CountClaims(element);
            Assert.IsTrue(count == 0, "The count of claims is not as expected");
        }
        /// <summary>
        /// Tests the get claims method
        /// </summary>
        [TestMethod]
        public void GetClaimTest()
        {
            const string InputFilePath = @"..\..\..\Acme.BizTalk.Orchestrations.Utilities.Tests\ClaimLoadingProcessHelperTests.xml";
            XElement element = XElement.Load(InputFilePath);
            Claim claim = ClaimLoadingProcessHelper.GetClaim(element, 2); //Its zero based
            Assert.IsNotNull(claim, "The claim should not be null");
        }
    }
}
